home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Util / B / Bench.cpt / Bench / DiskBench.asm next >
Assembly Source File  |  1992-03-24  |  6KB  |  268 lines

  1. ; DiskBench.Asm        25-Mar-86    Steve Brecher
  2. ;
  3. ; Version    1.0    ;run on DataFrame at LA MUG meeting 20-Mar-86
  4. ; Version    1.1    ;fix DITL resource ID in ALRT 130 (error alert)
  5. ;            ;provide Rmaker file so Consulair linker not needed
  6. ; Version    2.0    ;bug fix:  change _NewPtr to _NewHandle
  7. ; Version    3.0    ;Ephraim Vishniac  April 9, 1986
  8. ;            ;Dither between operations to remove bias
  9. ;
  10. ; This program does a performance test on the volume from which it is launched:
  11. ;    Data transfer speed:
  12. ;        32KB reads from start of volume
  13. ;        32KB writes to start of volume
  14. ;        (32KB is choosen as a reasonably-large size that is not likely
  15. ;         to cross a cylinder boundary).
  16. ;    Access time:
  17. ;        1 512-byte read from block 0 followed by 1 512-byte read
  18. ;            from offset 1MB (volume must be at least 1MB+512bytes large)
  19. ;
  20. ; Each test is performed multiple times.
  21. ;
  22. ; The write tests use the data that was previously read, so the test is
  23. ; non-destructive.
  24.  
  25.     Include    MacTraps.D
  26.     Include    SysEqu.D
  27.     Include    FSEqu.D
  28.  
  29. XferSize    Equ    32*1024
  30. WaitDlogID    Equ    128
  31. ResultsDlogID    Equ    129
  32. ErrorAlertID    Equ    130
  33. TransferCount    Equ    100    ;number of times to perform data transfer tests
  34. AccessCount    Equ    40    ;number of times to perform access time test
  35.  
  36. ;
  37. ; Global variables
  38. ;
  39. DlogPtr        DS.L    1    ;pointer to dialog record
  40. BuffHndl    DS.L    1    ;handle to I/O buffer
  41. ioPB        DS.B    ioQElSize ;I/O parameter block
  42. XferRdTicks    DS.L    1    ;ticks for data transfer test, reads
  43. XferWtTicks    DS.L    1    ;ticks for data transfer test, writes
  44. AccessTicks    DS.L    1    ;ticks for access time test
  45. XferRdStr    DS.B    8    ;strings for ASCII results...
  46. XferWtStr    DS.B    8
  47. AccessStr    DS.B    8
  48.  
  49. ErrorStr    DS.B    8    ;string for error code
  50. SkipAccess    DS.B    1    ;flag to skip access tests if volume too small
  51.  
  52.  
  53.     XDEF    Start
  54.  
  55. Start:    MoveQ    #0,D0
  56.     SubQ    #1,D0        ;all-events mask
  57.     _FlushEvents
  58.     Pea    -4(A5)
  59.     _InitGraf
  60.     _InitFonts
  61.     _InitWindows
  62.     _TEInit
  63.  
  64.     Clr.L    -(SP)
  65.  
  66.     _InitDialogs
  67.     SubQ    #4,SP        ;put up "Please wait" dialog...
  68.     Move    #WaitDlogID,-(SP)
  69.     Clr.L    -(SP)
  70.     MoveQ    #-1,D0
  71.     Move.L    D0,-(SP)
  72.     _GetNewDialog
  73.     Move.L    (SP),DlogPtr(A5)
  74.     Move.L    (SP),-(SP)
  75.     Move.L    (SP),-(SP)
  76.     Move.L    (SP),-(SP)
  77.     _BeginUpdate
  78.  
  79.     _DrawDialog
  80.     _EndUpdate
  81.     Move.L    #XferSize,D0    ;get reloc block for I/O buffer...
  82.     _NewHandle
  83.     Bne    Error
  84.     Move.L    A0,BuffHndl(A5)
  85.     Move.L    Time,D0        ;use time for random number seed
  86.     Move.L    D0,RndSeed
  87. ;
  88. ; Get disk driver refNum and default volume's drive number into ioPB
  89. ;
  90.     Move.L    FCBsPtr,A0
  91.     Add    CurApRefNum,A0    ;pointer to this application file's FCB
  92.     Move.L    fcbVPtr(A0),A0    ;pointer to VCB
  93.     Move    vcbDRefNum(A0),ioPB+ioRefNum(A5)
  94.     Move    vcbDrvNum(A0),ioPB+ioDrvNum(A5)
  95. ;
  96. ; Set flag to skip access test if volume too small
  97. ;
  98.     Clr.B    SkipAccess(A5)    ;assume large enough
  99.     Tst.W    vcbAlBlkSiz(A0)    ;if alloc block size > 64KB...
  100.     Bne.S    Setup        ;then assume volume large enough
  101.     Move.L    vcbAlBlkSiz(A0),D0
  102.     Mulu    vcbNmAlBlks(A0),D0 ;byte size of volume
  103.     Cmp.L    #(1024*1024)+512,D0
  104.     Slo    SkipAccess(A5)
  105. ;
  106. ; Set up rest of ioPB for data transfer tests
  107. ;
  108. Setup:
  109.     Lea    ioPB(A5),A0
  110.     Move.L    BuffHndl(A5),A1
  111.     Move.L    (A1),ioBuffer(A0)
  112.     Move.L    #XferSize,ioReqCount(A0)
  113.     Move    #fsFromStart,ioPosMode(A0)
  114. ;
  115. ; Do an initial read to seek to start of volume
  116. ; (don't count seek time in transfer tests)
  117. ;
  118.     Clr.L    ioPosOffset(A0)
  119.     _Read
  120.     Bne    Error
  121. ;
  122. ; Perform data transfer tests:  reads
  123. ;
  124.     MoveQ    #TransferCount-1,D1    ;number of iterations, adusted for Dbra
  125.     Clr.L    D2            ;running total time of test
  126. @0    Sub.L    Ticks,D2        ;subtract starting time, this pass
  127.     Clr.L    ioPosOffset(A0)
  128.     _Read
  129.     Bne    Error
  130.     Add.L    Ticks,D2        ;add ending time, this pass
  131.     Jsr    Dither            ;dither between passes
  132.  
  133.     Dbra    D1,@0
  134.     Move.L    D2,XferRdTicks(A5)
  135. ;
  136. ; Perform data transfer tests:  writes
  137. ;
  138.     MoveQ    #TransferCount-1,D1
  139.     Clr.L    D2
  140. @1    Sub.L    Ticks,D2
  141.     Clr.L    ioPosOffset(A0)
  142.     _Write
  143.     Bne    Error
  144.     Add.L    Ticks,D2
  145.     Jsr    Dither
  146.  
  147.     Dbra    D1,@1
  148.     Move.L    D2,XferWtTicks(A5)
  149. ;
  150. ; Perform access time test (unless volume too small)
  151. ;
  152.     Tst.B    SkipAccess(A5)
  153.     Bne.S    Results
  154.     Move.L    #512,ioReqCount(A0)    ;read one block at each location
  155.     MoveQ    #AccessCount-1,D1    ;number of iterations, adjusted for Dbra
  156.     Clr.L    D2
  157. @2    Sub.L    Ticks,D2
  158.     Move.L    #1024*1024,ioPosOffset(A0)
  159.     _Read
  160.     Bne    Error
  161.     Clr.L    ioPosOffset(A0)
  162.     _Read
  163.     Bne    Error
  164.  
  165.     Add.L    Ticks,D2
  166.     Jsr    Dither
  167.     Dbra    D1,@2
  168.     Move.L    D2,AccessTicks(A5)
  169. ;
  170. ; Convert results to ASCII and call ParamText with resulting strings
  171. ;
  172. Results:
  173.     Move.L    XferRdTicks(A5),D0
  174.     Lea    XferRdStr(A5),A0
  175.     Move.L    A0,-(SP)
  176.     Clr    -(SP)            ;NumToString
  177.     _Pack7
  178.     Move.L    XferWtTicks(A5),D0
  179.     Lea    XferWtStr(A5),A0
  180.     Move.L    A0,-(SP)
  181.     Clr    -(SP)            ;NumToString
  182.     _Pack7
  183.     Pea    '(Volume too small)'    ;assume no access test was done
  184.     Tst.B    SkipAccess(A5)
  185.     Bne.S    @0            ;correct
  186.     Move.L    AccessTicks(A5),D0
  187.     Lea    AccessStr(A5),A0
  188.     Move.L    A0,(SP)
  189.     Clr    -(SP)            ;NumToString
  190.     _Pack7
  191. @0    Clr.L    -(SP)
  192.  
  193.     _ParamText
  194. ;
  195. ; Take down "Please wait" and put up results dialog
  196. ;
  197.     Move.L    DlogPtr(A5),-(SP)
  198.     _DisposDialog
  199.     SubQ    #4,SP
  200.     Move    #ResultsDlogID,-(SP)
  201.     Clr.L    -(SP)
  202.     MoveQ    #-1,D0
  203.     Move.L    D0,-(SP)
  204.     _GetNewDialog            ;just leave result on stack
  205. ;
  206. ; Wait for OK button, then quit
  207. ;
  208.     _InitCursor
  209.     SubQ    #2,SP            ;space for itemHit
  210.     Clr.L    -(SP)            ;filterProc
  211.     Pea    4(SP)            ;addr of itemHit
  212.     _ModalDialog
  213.     _ExitToShell
  214. ;
  215. ; Display cause of fatal error and quit
  216. ; D0 = error code
  217. ;
  218. Error:    Lea    ErrorStr(A5),A0
  219.  
  220.     Move.L    A0,-(SP)        ;for ParamText
  221.     Ext.L    D0
  222.     Clr    -(SP)
  223.     _Pack7                ;convert error code to ASCII
  224.     Clr.L    -(SP)
  225.     Clr.L    -(SP)
  226.     Clr.L    -(SP)
  227.     _ParamText
  228.     Move.L    DlogPtr(A5),-(SP)    ;take down "Please wait"...
  229.     _DisposDialog
  230.     _InitCursor
  231.     SubQ    #2,SP
  232.  
  233.     Move    #ErrorAlertID,-(SP)
  234.     Clr.L    -(SP)
  235.     _StopAlert
  236.     _ExitToShell
  237.  
  238. ;    Dither: Waste some time to remove rotational positioning bias.
  239. ;    A hard disk typically rotates a couple thousand RPM, which
  240. ;    is about .5 to 1 rotations per tick.  A loop with _GetNextEvent
  241. ;    goes about 5 iterations per tick, so a delay of 1 to 64 iterations
  242. ;    will hold us up from zero to 12 ticks - plenty of time to randomize
  243. ;    the disk's rotational position.
  244. ;    EMV  April 9, 1986
  245. Dither
  246.     Movem.L    D1-D2/A0,-(SP)    ; save registers used in test loop
  247.     Clr.W    -(SP)        ; for random integer
  248.     _Random
  249.     Move.W    (SP)+,D3    ; -32767 <= D3 <= 32767
  250.     And.L    #63,D3        ; 0 <= D3 <= 63
  251. DitherLoop
  252.     Clr.W    -(SP)        ; for result of _GetNextEvent
  253.     Move.W    #-1,-(SP)    ; any event is acceptable
  254.     Pea    EventRecord    ; place to store event
  255.     _GetNextEvent
  256.     Tst.W    (SP)+        ; discard result
  257.     Dbra    D3,DitherLoop    ; just get another event
  258.  
  259.     Movem.L    (SP)+,D1-D2/A0    ; restore registers
  260.     Rts
  261.  
  262. EventRecord
  263.     Dcb.B    evtBlkSize,0    ; space for event record
  264.  
  265.  
  266.     End
  267.  
  268.